<template>
	<view class="all">
		<view class="title">
			欢迎登录孝夕阳居家养老服务
		</view>
		<view class="body">
			<view class="box">
				<image class="img1" src="../../static/logo.png" mode=""></image>
				<view class="text">
					孝夕阳居家养老服务
				</view>
			</view>
		</view>
		<view class="last" @click="login()">
			一键注册登录
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: ""
			};
		},
		onLoad(option) {
			if (location.search) {
				this.$api('/addons/third/api/callback', 'post', {
					code: location.search.split('=')[1].split("&")[0]
				}).then((res) => {
					console.log(res);
					uni.$u.toast('登陆成功')
					uni.setStorageSync('token', res.data.data.user.token)
					setTimeout(() => {
						uni.switchTab({
							url: '/pages/index/index'
						}, 1000)
					})
				}).catch((err) => {
					console.log(err);
				})
			}
		},
		methods: {
			login() {
				this.$api('/addons/third/api/getAuthUrl', 'post').then((res) => {
					console.log(res);
					console.log(res.data.data);
					this.list = res.data.data
					window.location.href = res.data.data
				}).catch((err) => {
					console.log(err);
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.all {
		padding: 15px;

		.title {
			font-size: 20px;
			font-family: PingFang SC, PingFang SC;
			font-weight: bold;
			color: #333333;
		}

		.body {
			width: 100%;
			height: 200px;
			display: flex;
			align-items: center;
			justify-content: center;

			.box {
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;

				.img1 {
					width: 96px;
					height: 96px;
					background: #FFFFFF;
					box-shadow: 0px 3px 6px 1px rgba(0, 0, 0, 0.16);
					border-radius: 20px;
					margin: 0 0 10px 0;
				}

				.text {
					font-size: 16px;
					font-family: PingFang SC, PingFang SC;
					font-weight: bold;
					color: #333333;
					text-align: center;
				}
			}


		}

		.last {
			width: 90%;
			position: fixed;
			bottom: 30%;
			background: #FB774B;
			border-radius: 40px;
			padding: 10px 0;
			text-align: center;

			font-size: 16px;
			font-family: PingFang SC, PingFang SC;
			font-weight: bold;
			color: #FFFFFF;
		}
	}
</style>